package com.xzzz.irda.auth.server;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 从Bean中获取 {@link AuthServerConfigurer}实现对象
 *
 * @author wangyf
 * 
 */
@Slf4j
final class AutowiredAuthServiceConfigurersIgnoreParents {

	private final ConfigurableListableBeanFactory beanFactory;

	AutowiredAuthServiceConfigurersIgnoreParents(ConfigurableListableBeanFactory beanFactory) {
		this.beanFactory = beanFactory;
	}

    /**
     * 获取全部类型为{@link AuthServerConfigurer}的bean
     */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public List<AuthServerConfigurer> getArthurServiceConfigurers() {
		List<AuthServerConfigurer> arthurServerConfigurers = new ArrayList<>();
		Map<String, AuthServerConfigurer> beansOfType = beanFactory.getBeansOfType(AuthServerConfigurer.class);
		for (Map.Entry<String, AuthServerConfigurer> entry : beansOfType.entrySet()) {
            arthurServerConfigurers.add(entry.getValue());
		}
		return arthurServerConfigurers;
	}
}
